//
//  MWFilterModel.m
//  XiRan-iOS
//
//  Created by liuyiming on 2019/10/28.
//  Copyright © 2019 Wood. All rights reserved.
//

#import "MWFilterModel.h"

@implementation MWFilterModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"mid" : @"id"};
}

+ (NSDictionary *)mj_objectClassInArray {
    return @{@"attr_list" : @"MWAttribute"};
}

- (void)addCustomAttribute
{
    if(self.mid == 81 ||
       self.mid == 50 ||
       self.mid == 54 ||
       self.mid == 51) {
        MWAttribute *customAttribute = [MWAttribute new];
        customAttribute.mid = -1;
        customAttribute.attr_tran = @"自定义";
        customAttribute.attr_value = @"自定义";
        self.attr_list = [[self.attr_list arrayByAddingObject:customAttribute] mutableCopy];
    }
}

- (NSString *)customTypeString
{
    if(self.mid == 81) {
        return @"zhijing";
    } else if(self.mid == 50) {
        return @"length";
    } else if(self.mid == 54) {
        return @"width";
    } else if(self.mid == 51) {
        return @"gaodu";
    }
    return @"";
}

@end

@implementation MWAttribute
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"mid" : @"id", @"attr_list" : @"attr_list2"};
}

+ (NSDictionary *)mj_objectClassInArray {
    return @{@"attr_list" : @"MWSubattribute"};
}

- (NSString *)showAttr_value
{
    if(self.mid < 0) {
        if(self.customValue.length == 0) {
            return self.attr_value;
        }
        return self.customValue;
    }
    return self.attr_value;
}

@end

@implementation MWSubattribute

+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"mid" : @"id"};
}

@end
